package com.qf.java2103.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.java2103.mapper.EquipmentMapper;
import com.qf.java2103.pojo.Equipment;
import com.qf.java2103.service.EquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EquipmentServiceImpl implements EquipmentService {


    @Autowired
    private EquipmentMapper equipmentMapper;

    @Override
    public List<Equipment> getList(Long buildingEquipment) {
        return equipmentMapper.selectAll(buildingEquipment);
    }

    @Override
    public int edit(Equipment equipment) {
        int edit = equipmentMapper.updateByPrimaryKey(equipment);
        return edit;
    }

    @Override
    public int deleteById(Long id) {
        int delete = equipmentMapper.deleteByPrimaryKey(id);
        return delete;
    }

    @Override
    public int add(Equipment equipment) {
        int insert = equipmentMapper.insert(equipment);
        return insert;
    }

    @Override
    public Equipment selectById(Long id) {
        return equipmentMapper.selectById(id);
    }

    @Override
    public List selectByName(String name){
        QueryWrapper<Object> wrapper = new QueryWrapper<>();
        wrapper.like("name",name);
        return equipmentMapper.selectByName(name);

    }

}
